package tianrun.ziguan.api.calculate.config.dto.response;

import tianrun.ziguan.api.calculate.config.constant.StringPools;
import tianrun.ziguan.api.calculate.config.dto.request.AssetStaticPropertiesInstanceVO;

import java.math.BigDecimal;

public class IotValue {
    private String deviceName;
    private String label;
    private BigDecimal value;
    private Long time;
    private String orgId;
    private String type;


    public static IotValue of(AssetStaticPropertiesInstanceVO instance) {
        IotValue iotValue = new IotValue();
        iotValue.setDeviceName(instance.getAssetNum());
        iotValue.setLabel(instance.getLabel());
        iotValue.setType(StringPools.STATIC_DATA);
        iotValue.setTime(-2L);
        try {
            iotValue.setValue(new BigDecimal(instance.getValue()));
        }catch (Exception e){
            return null;
        }
        return iotValue;
    }

    public String getDeviceName() {
        return deviceName;
    }

    public void setDeviceName(String deviceName) {
        this.deviceName = deviceName;
    }

    public String getLabel() {
        return label;
    }

    public void setLabel(String label) {
        this.label = label;
    }

    public BigDecimal getValue() {
        return value;
    }

    public void setValue(BigDecimal value) {
        this.value = value;
    }

    public Long getTime() {
        return time;
    }

    public void setTime(Long time) {
        this.time = time;
    }

    public String getOrgId() {
        return orgId;
    }

    public void setOrgId(String orgId) {
        this.orgId = orgId;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }
}
